/*
	接受家族的程序 
*/
package net.sf.odinms.net.channel.handler;

import net.sf.odinms.client.MapleCharacter;
import net.sf.odinms.client.MapleClient;
import net.sf.odinms.net.AbstractMaplePacketHandler;
import net.sf.odinms.net.channel.ChannelServer;
import net.sf.odinms.tools.MaplePacketCreator;
import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;

/**
 *
 * @author
 */
public final class AcceptFamilyHandler extends AbstractMaplePacketHandler {
    private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(AcceptFamilyHandler.class);

    public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
        log.info("111111111111111111");
        System.out.println(slea.toString());
        int inviterId = slea.readInt();
//        String inviterName = slea.readMapleAsciiString();
        MapleCharacter inviter = ChannelServer.getCharacterFromAllServers(inviterId);
        if (inviter != null) {
            inviter.getClient().getSession().write(MaplePacketCreator.sendFamilyJoinResponse(true, c.getPlayer().getName()));
        }
        c.getSession().write(MaplePacketCreator.sendFamilyMessage());
    }
}